package com.tdtxdcxm.ruralcommunity.slice;

import com.tdtxdcxm.ruralcommunity.ResourceTable;
import com.tdtxdcxm.ruralcommunity.appruntime.DataCenterControl;
import com.tdtxdcxm.ruralcommunity.httpmanagers.ThreadPoolUtil;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.net.NetHandle;
import ohos.net.NetManager;
import ohos.net.NetStatusCallback;
import ohos.utils.zson.ZSONObject;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;

public class XmDetails extends AbilitySlice {
    private String contentid= "";
    private String userid = "";

    private Button xm_detail_topddl_nobut,xm_detail_authorbut,xm_detail_topddl_discussbut,xm_detail_topddl_agreebut,xm_detail_topddl_collectbut;
    private Text xm_detail_authortext,xm_detail_fieldtext,xm_detail_titletext,xm_detail_nodeonetext,xm_detail_nodetwotext,xm_detail_nodethreetext,xm_detail_contenttext;


    /*<****************http发送点击阅读指令区域*****************/
    public void UpDataWorldListReadInfo(String content_id,String user_id){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;

            String urlString = DataCenterControl.serverIpWithPort + "read/?";

            try {
                URL url = new URL(urlString);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();

                    stringBuilder.append("username=");
                    stringBuilder.append(DataCenterControl.userName);

                    stringBuilder.append("&content_id=");
                    stringBuilder.append(content_id);

                    stringBuilder.append("&user_id=");
                    stringBuilder.append(user_id);

                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);
                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();

                    String[] tosettext = {"","",""};
                    if(result.startsWith("ok:")){
                        result = result.substring(3);
                        if(result.charAt(0) == '0'){
                            tosettext[0] = "关注";
                        }
                        else{
                            tosettext[0] = "已关注";
                        }
                        if(result.charAt(1) == '0'){
                            tosettext[1] = "点赞";
                        }
                        else{
                            tosettext[1] = "已点赞";
                        }
                        if(result.charAt(2) == '0'){
                            tosettext[2] = "收藏";
                        }
                        else{
                            tosettext[2] = "已收藏";
                        }

                        getUITaskDispatcher().asyncDispatch(new Runnable() {
                            @Override
                            public void run() {
                                xm_detail_authorbut.setText(tosettext[0]);
                                xm_detail_topddl_agreebut.setText(tosettext[1]);
                                xm_detail_topddl_collectbut.setText(tosettext[2]);
                            }
                        });
                    }

                }
            } catch (IOException e) {} finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http发送点击阅读指令区域***************>*/

    /*<****************http发送点赞或收藏指令区域*****************/
    public void UpDataAgreeAndCollectInfo(String content_id,String operation){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;
            String urlString = "";
            if(operation.equals("点赞")){
                urlString = DataCenterControl.serverIpWithPort + "agree/?";
            }
            if(operation.equals("收藏")){
                urlString = DataCenterControl.serverIpWithPort + "collect/?";
            }
            if(operation.equals("取消点赞")){
                urlString = DataCenterControl.serverIpWithPort + "unagree/?";
            }
            if(operation.equals("取消收藏")){
                urlString = DataCenterControl.serverIpWithPort + "uncollect/?";
            }

            try {
                URL url = new URL(urlString);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();

                    stringBuilder.append("username=");
                    stringBuilder.append(DataCenterControl.userName);

                    stringBuilder.append("&contentid=");
                    stringBuilder.append(content_id);

                    stringBuilder.append("&time=");
                    SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date date = new Date(System.currentTimeMillis());
                    stringBuilder.append(formatter.format(date));

                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);
                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();

                    String[] tosettext = {"","",""};
                    if(result.equals("OK")){
                        if(operation.equals("点赞")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_topddl_agreebut.setText("已点赞");
                                }
                            });
                        }
                        if(operation.equals("收藏")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_topddl_collectbut.setText("已收藏");
                                }
                            });
                        }
                        if(operation.equals("取消点赞")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_topddl_agreebut.setText("点赞");
                                }
                            });
                        }
                        if(operation.equals("取消收藏")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_topddl_collectbut.setText("收藏");
                                }
                            });

                        }
                    }
                }
            } catch (IOException e) {} finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http发送点赞或收藏指令区域***************>*/

    /*<****************http发送关注或取消关注指令区域*****************/
    public void UpDataFollowInfo(String user_id,String operation){
        NetManager main_toplistnetmanger = NetManager.getInstance(this.getContext());
        if (!main_toplistnetmanger.hasDefaultNet()) {
            return;
        }
        ThreadPoolUtil.submit(() -> {
            NetHandle thenetHandle = main_toplistnetmanger.getDefaultNet();
            NetStatusCallback netStatusCallback = new NetStatusCallback() {};
            HttpURLConnection httpURLConnection = null;
            String urlString = "";
            if(operation.equals("关注")){
                urlString = DataCenterControl.serverIpWithPort + "follow/?";
            }
            if(operation.equals("取消关注")){
                urlString = DataCenterControl.serverIpWithPort + "unfollow/?";
            }

            try {
                URL url = new URL(urlString);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                URLConnection urlConnection = thenetHandle.openConnection(url, java.net.Proxy.NO_PROXY);
                if (urlConnection instanceof HttpURLConnection) {
                    httpURLConnection = (HttpURLConnection) urlConnection;
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);

                    StringBuilder stringBuilder = new StringBuilder();

                    stringBuilder.append("username=");
                    stringBuilder.append(DataCenterControl.userName);

                    stringBuilder.append("&user_id=");
                    stringBuilder.append(user_id);


                    byte[] b = stringBuilder.toString().getBytes();
                    httpURLConnection.getOutputStream().write(b);
                    try {
                        httpURLConnection.connect();
                    } catch (IOException e) {}
                    outputStream.flush();


                    InputStream inputStream = null;
                    try {
                        inputStream = urlConnection.getInputStream();
                        byte[] cache = new byte[2 * 1024];
                        int len = inputStream.read(cache);
                        while (len != -1) {
                            outputStream.write(cache, 0, len);
                            len = inputStream.read(cache);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = "";
                    result = outputStream.toString();

                    String[] tosettext = {"","",""};
                    if(result.equals("OK")){
                        if(operation.equals("关注")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_authorbut.setText("已关注");
                                }
                            });
                        }
                        if(operation.equals("取消关注")){
                            getUITaskDispatcher().asyncDispatch(new Runnable() {
                                @Override
                                public void run() {
                                    xm_detail_authorbut.setText("关注");
                                }
                            });
                        }
                    }
                }
            } catch (IOException e) {

            } finally {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            }
        });
    }
    /******************http发送关注或取消关注指令区域***************>*/

    private void initDtWzDtASComponents(String listContainerName,int i){
        xm_detail_topddl_nobut = (Button) findComponentById(ResourceTable.Id_xm_detail_topddl_nobut);
        xm_detail_authorbut = (Button) findComponentById(ResourceTable.Id_xm_detail_authorbut);
        xm_detail_topddl_discussbut = (Button) findComponentById(ResourceTable.Id_xm_detail_topddl_discussbut);
        xm_detail_topddl_agreebut = (Button) findComponentById(ResourceTable.Id_xm_detail_topddl_agreebut);
        xm_detail_topddl_collectbut = (Button) findComponentById(ResourceTable.Id_xm_detail_topddl_collectbut);

        xm_detail_authortext = (Text) findComponentById(ResourceTable.Id_xm_detail_authortext);
        xm_detail_fieldtext = (Text) findComponentById(ResourceTable.Id_xm_detail_fieldtext);

        xm_detail_titletext = (Text) findComponentById(ResourceTable.Id_xm_detail_titletext);
        xm_detail_nodeonetext = (Text) findComponentById(ResourceTable.Id_xm_detail_nodeonetext);
        xm_detail_nodetwotext = (Text) findComponentById(ResourceTable.Id_xm_detail_nodetwotext);
        xm_detail_nodethreetext = (Text) findComponentById(ResourceTable.Id_xm_detail_nodethreetext);

        xm_detail_contenttext = (Text) findComponentById(ResourceTable.Id_xm_detail_contenttext);

        switch (listContainerName) {
            case "worlddtlc":
                break;
            case "worldxmlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.worldxm_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.worldxm_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.worldxm_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_xm = ZSONObject.stringToZSON(DataCenterControl.worldxm_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_xm.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_xm.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_xm.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_xm.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_xm.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.worldxm_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.worldxm_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.worldxm_listcontainer_list.get(i).getContent_id()
                                        ,DataCenterControl.worldxm_listcontainer_list.get(i).getUser_id());
                break;
            case "worldwzlc":
                break;
            case "artlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.art_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.art_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.art_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_art = ZSONObject.stringToZSON(DataCenterControl.art_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_art.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_art.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_art.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_art.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_art.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.art_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.art_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.art_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.art_listcontainer_list.get(i).getUser_id());
                break;
            case "clothelc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.clothe_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.clothe_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.clothe_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_clothe = ZSONObject.stringToZSON(DataCenterControl.clothe_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_clothe.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_clothe.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_clothe.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_clothe.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_clothe.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.clothe_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.clothe_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.clothe_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.clothe_listcontainer_list.get(i).getUser_id());
                break;
            case "foodlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.food_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.food_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.food_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_food = ZSONObject.stringToZSON(DataCenterControl.food_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_food.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_food.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_food.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_food.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_food.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.food_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.food_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.food_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.food_listcontainer_list.get(i).getUser_id());
                break;
            case "houselc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.house_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.house_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.house_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_house = ZSONObject.stringToZSON(DataCenterControl.house_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_house.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_house.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_house.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_house.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_house.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.house_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.house_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.house_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.house_listcontainer_list.get(i).getUser_id());
                break;
            case "trafficlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.traffic_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.traffic_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.traffic_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_traffic = ZSONObject.stringToZSON(DataCenterControl.traffic_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_traffic.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_traffic.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_traffic.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_traffic.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_traffic.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.traffic_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.traffic_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.traffic_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.traffic_listcontainer_list.get(i).getUser_id());
                break;
            case "studylc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.study_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.study_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.study_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_study = ZSONObject.stringToZSON(DataCenterControl.study_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_study.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_study.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_study.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_study.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_study.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.study_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.study_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.study_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.study_listcontainer_list.get(i).getUser_id());
                break;
            case "culturelc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.culture_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.culture_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.culture_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_culture = ZSONObject.stringToZSON(DataCenterControl.culture_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_culture.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_culture.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_culture.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_culture.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_culture.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.culture_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.culture_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.culture_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.culture_listcontainer_list.get(i).getUser_id());
                break;
            case "userdtlc":
                break;
            case "userxmlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.userxm_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.userxm_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.userxm_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_userxm = ZSONObject.stringToZSON(DataCenterControl.userxm_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_userxm.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_userxm.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_userxm.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_userxm.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_userxm.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.userxm_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.userxm_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.userxm_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.userxm_listcontainer_list.get(i).getUser_id());
                break;
            case "userwzlc":
                break;
            case "usercollectlc":
                //不能自己关注自己，不能自己点赞、评论、收藏自己
                if(DataCenterControl.userName.equals(DataCenterControl.usercollect_listcontainer_list.get(i).getUser_id())){
                    xm_detail_authorbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_discussbut.setVisibility(Component.HIDE);
                    xm_detail_topddl_agreebut.setVisibility(Component.HIDE);
                    xm_detail_topddl_collectbut.setVisibility(Component.HIDE);
                }
                else {
                    xm_detail_authorbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                    xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                }
                xm_detail_authortext.setText(DataCenterControl.usercollect_listcontainer_list.get(i).getUser_id());
                xm_detail_fieldtext.setText(DataCenterControl.usercollect_listcontainer_list.get(i).getField_id());
                ZSONObject zsonobject_usercollect = ZSONObject.stringToZSON(DataCenterControl.usercollect_listcontainer_list.get(i).getDetail());
                xm_detail_titletext.setText("项 目 |"+"\t"+zsonobject_usercollect.getString("title"));
                xm_detail_nodeonetext.setText("节点1|"+"\t"+zsonobject_usercollect.getString("nodeone"));
                xm_detail_nodetwotext.setText("节点2|"+"\t"+zsonobject_usercollect.getString("nodetwo"));
                xm_detail_nodethreetext.setText("节点3|"+"\t"+zsonobject_usercollect.getString("nodethree"));
                xm_detail_contenttext.setText(zsonobject_usercollect.getString("detail").replace("\\n","\n"));
                contentid = DataCenterControl.usercollect_listcontainer_list.get(i).getContent_id();
                userid = DataCenterControl.usercollect_listcontainer_list.get(i).getUser_id();
                UpDataWorldListReadInfo(DataCenterControl.usercollect_listcontainer_list.get(i).getContent_id()
                        ,DataCenterControl.usercollect_listcontainer_list.get(i).getUser_id());
                break;
            default:
                break;
        }


        xm_detail_authorbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(xm_detail_authorbut.getText().equals("关注")){
                    UpDataFollowInfo(userid,"关注");
                    return;
                }
                if(xm_detail_authorbut.getText().equals("已关注")){
                    UpDataFollowInfo(userid,"取消关注");
                    return;
                }
            }
        });
        xm_detail_topddl_nobut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                xm_detail_authorbut.setText("加载中...");
                xm_detail_topddl_agreebut.setText("加载中...");
                xm_detail_topddl_collectbut.setText("加载中...");

                xm_detail_authorbut.setVisibility(Component.VISIBLE);
                xm_detail_topddl_discussbut.setVisibility(Component.VISIBLE);
                xm_detail_topddl_agreebut.setVisibility(Component.VISIBLE);
                xm_detail_topddl_collectbut.setVisibility(Component.VISIBLE);
                terminate();
            }
        });
        xm_detail_topddl_discussbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                present(new ContentDiscussSlice(),new Intent().setParam("contentid",contentid));
            }
        });
        xm_detail_topddl_agreebut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(xm_detail_topddl_agreebut.getText().equals("点赞")){
                    UpDataAgreeAndCollectInfo(contentid,"点赞");
                    return;
                }
                if(xm_detail_topddl_agreebut.getText().equals("已点赞")){
                    UpDataAgreeAndCollectInfo(contentid,"取消点赞");
                    return;
                }
            }
        });
        xm_detail_topddl_collectbut.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if(xm_detail_topddl_collectbut.getText().equals("收藏")){
                    UpDataAgreeAndCollectInfo(contentid,"收藏");
                    return;
                }
                if(xm_detail_topddl_collectbut.getText().equals("已收藏")){
                    UpDataAgreeAndCollectInfo(contentid,"取消收藏");
                    return;
                }
            }
        });
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_xm_details);

        initDtWzDtASComponents(intent.getStringParam("listContainerName"),intent.getIntParam("i",-1));
    }

    @Override
    protected void onActive() {
        super.onActive();
    }

    @Override
    protected void onInactive() {
        super.onInactive();
    }

    @Override
    protected void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    protected void onBackground() {
        super.onBackground();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}
